package com.ldc.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ldc.model.UserInfo;
import com.ldc.service.mapper.UserInfoMapper;
import com.ldc.service.service.UserInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能描述
 *
 * @author liudi
 * @since 2023/7/22
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {
    @Override
    public UserInfo findBy(LambdaQueryWrapper<UserInfo> queryWrapper) {
        return getOne(queryWrapper);
    }

    @Override
    public UserInfo findByUserId(long userId) {
        return findBy(new QueryWrapper<UserInfo>().lambda().eq(UserInfo::getUid, userId));
    }

    @Override
    public int batchDeleteBy(LambdaQueryWrapper<UserInfo> queryWrapper) {
        return getBaseMapper().delete(queryWrapper);
    }

    @Override
    public int batchDeleteByUIds(List<Long> uids) {
        return batchDeleteBy(new LambdaQueryWrapper<UserInfo>().in(UserInfo::getUid, uids));
    }
}
